/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.core.service.jdbc;

/**
 * 
 * @author 刘威
 */
import java.util.Date;
import java.sql.Timestamp;
import java.util.HashMap;

public class DBRow {

	HashMap map = new HashMap();

	public void addCell(String key, Object value) {
		this.map.put(key, value);
	}

	public String getString(String key) {
		String ret = "";
		try {
			ret = this.map.get(key).toString();
		} catch (Exception ex) {
		}
		return ret;
	}

	public int getInt(String key) {
		int ret = 0;
		try {
			ret = Integer.parseInt(this.map.get(key).toString());
		} catch (Exception ex) {
		}
		return ret;
	}

	public double getDouble(String key) {
		double ret = 0D;
		try {
			ret = Double.parseDouble(this.map.get(key).toString());
		} catch (Exception ex) {
		}
		return ret;
	}

	public float getFloat(String key) {
		float ret = 0F;
		try {
			ret = Float.parseFloat(this.map.get(key).toString());
		} catch (Exception ex) {
		}
		return ret;
	}

	public boolean getBoolean(String key) {
		boolean ret = false;
		try {
			ret = ((Boolean) this.map.get(key)).booleanValue();
		} catch (Exception ex) {
		}
		return ret;
	}

	public byte getByte(String key) {
		byte ret = 0;
		try {
			ret = Byte.parseByte(this.map.get(key).toString());
		} catch (Exception ex) {
		}
		return ret;
	}

	public long getLong(String key) {
		long ret = 0L;
		try {
			ret = Long.parseLong(this.map.get(key).toString());
		} catch (Exception ex) {
		}
		return ret;
	}

	public short getShort(String key) {
		short ret = 0;
		try {
			ret = Short.parseShort(this.map.get(key).toString());
		} catch (Exception ex) {
		}
		return ret;
	}

	public Date getDate(String key) {
		Date ret = null;
		try {
			Timestamp objTimestamp = (Timestamp) this.map.get(key);
			if (objTimestamp != null) {
				ret = new Date(objTimestamp.getTime());
			}
		} catch (Exception ex) {
			ex.printStackTrace();
		}
		return ret;
	}

	public byte[] getBytes(String key) {
		byte[] ret = null;
		try {
			ret = (byte[]) this.map.get(key);

		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}
}
